<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/Static/Css/reset.css" />
<link rel="stylesheet" type="text/css" href="/Static/Css/zh-cn-system.css" />
<link rel="stylesheet" type="text/css" href="/Static/Css/table_form.css" />
<script src="/Public/js/jquery.min.js"></script>
<script src="/Public/js/jquery.form.js"></script>
<script src="/Public/js/main.js"></script>
<script type="text/javascript" src="/Public/artDialog/jquery.artDialog.js?skin=default"></script>
<script type="text/javascript" src="/Public/artDialog/plugins/iframeTools.js"></script>
</head>
<body>

<div class="subnav">
  <div class="explain-col" style="position: relative;">
    <form name="searchForm" id="searchForm" method="GET" action="/index.php/statis/index" onsubmit="return checkForm()">
      统计分析：
      <select name="searchType" id="searchType"  >
            <option value="1" selected="selected">本月</option>
            <option value="2" <?php if(($_GET['searchType']) == "2"): ?>selected="selected"<?php endif; ?> />上月</option>
            <option value="3" <?php if(($_GET['searchType']) == "3"): ?>selected="selected"<?php endif; ?> />本周</option>
            <option value="4" <?php if(($_GET['searchType']) == "4"): ?>selected="selected"<?php endif; ?> />上周</option>
            <option value="5" <?php if(($_GET['searchType']) == "5"): ?>selected="selected"<?php endif; ?> />今天</option>
            <option value="6" <?php if(($_GET['searchType']) == "6"): ?>selected="selected"<?php endif; ?> />昨天</option>
            <option value="10" <?php if(($_GET['searchType']) == "10"): ?>selected="selected"<?php endif; ?> />自定</option>
      </select>
      <span id="searchTime" style="display:none;">
      从：<input type="text" class="input-text Wdate" size="20" name="startTime" id="startTime" value="<?php echo (date('Y-m-d',(isset($_GET['startTime']) && ($_GET['startTime'] !== ""))?($_GET['startTime']):time())); ?>" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" />
      到&nbsp;<input type="text" class="input-text Wdate" size="20" name="endTime" id="endTime" value="<?php echo (date('Y-m-d H:i:s',(isset($_GET['endTime']) && ($_GET['endTime'] !== ""))?($_GET['endTime']):time())); ?>" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" />
      </span>

      <?php if(($showUserStatistics) == "1"): ?><select name="userId" id="userId" onchange="searchForm.submit();" >
            <option value="0" selected="selected">请选择用户</option>
            <?php if(is_array($userList)): $i = 0; $__LIST__ = $userList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>" <?php if(($_GET['userId']) == $vo["id"]): ?>selected="selected"<?php endif; ?> /><?php echo ($vo["username"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
      </select><?php endif; ?>
      <input type="submit" value=" 搜索 " class="button" />
    </form>
      <div class="content-menu" style="position: absolute; right: 30px;top: 5px;">
        <a href="javascript:openWinBox('/index.php/statis/statisticsColumn/year/<?php echo ($_GET['year']); ?>/month/<?php echo ($_GET['month']); ?>','柱型图',980,600)" class="add fb" ><em>统计图</em></a>
      </div>
  </div>
</div>
<!--subnav-->
<div class="pad-lr-10">
  <form name="myform" id="myform" action="/index.php/statis/deleteAll" method="GET">
    <div class="table-list">
	    <table width="100%" cellspacing="0">
	      <thead>
	        <tr>

	          <th align="center" >新客戶(人)</th>
	          <th align="center" >跟进客户(人)</th>
	          <th align="center" >跟进次数</th>
	        </tr>
	      </thead>
	      <tbody  id="list">
	      	<tr class="callList">
	           <td align="center" ><?php echo ($customer_new); ?></td>
	           <td align="center" class="clientNum" ><?php echo ($customer_old); ?></td>
	           <td align="center" ><?php echo ($record_num); ?></td>
	        </tr>
	      <!-- <tr>
	           <td align="center" >总量：</td>
	           <td align="center" ></td>
	           <td align="center" ><?php echo ($newConsumerTotal); ?></td>
	           <td align="center" ><?php echo ($telNumTotal); ?></td>
	           <td align="center" ><?php echo ($youxiaoTotal); ?></td>
	           <td align="center" ><?php echo ($wuxiaoTotal); ?></td>
	           <td align="center" >
	           </td>
	        </tr> -->
	      </tbody>
	    </table>
     </div>
    <div class="btn">
    	<span style="margin-right:10px; color:#000">说明：</span> 新客户某时间段新添加的客户，跟进客户为某时间段跟进的客户
    </div>
  </form>
</div>

</body>
</html>
<script type="text/javascript" src="/Public/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
$(function(){
	//赋予状态颜色
	$('.tjbg:odd').css("background-color", "#F4F4F8");
	$('.tjbg:even').css("background-color", "#EFF1F1");

	//合计

	$('#myform').ajaxForm({
		beforeSubmit:  checkForm,
		success:       complete,
		dataType: 'json'
	});
	function checkForm(){
		var len = $("input[name='spaceid[]']:checked").length;
		if(len < 1){
			msg('请先选择删除项！','warning',3);
			return false;
		}
	}

	var origin = $.artDialog.open.origin;
	function complete(data){
		msg(data.info,data.data);
		if(data.status) setTimeout(function(){origin.location.reload();},1500);
	}


	var searchType = "<?php echo ($_GET['searchType']); ?>";
	if(searchType==10){
		$("#searchTime").show();
	}else{
		$("#searchTime").hide();
	}
	$("#searchType").change(function(){
		var searchType = $(this).val();
		if(searchType==10){
			$("#searchTime").show();
			return false;
		}
		searchForm.submit();
	})

	var startTime = "<?php echo ($_GET['startTime']); ?>";
	var endTime = "<?php echo ($_GET['endTime']); ?>";
	if(startTime!=''){
		$("#startTime").val(startTime);
	}
	if(endTime!=''){
		$("#endTime").val(endTime);
	}


})

function exportExcel(){
	var box = $("input[name='idArr[]']:checked");
		len = box.length,
		idArr = "";
	for (var i = 0; i < box.length; i++){
		idArr += box[i].value + ",";
	}
	location.href="/index.php/Excel/exportExcel/idArr/"+idArr;
}

//修改状态
function changeStatus(id){
	var statusId = $("#status-"+id).attr('name');
	$.get("/index.php/statis/changeStatus/id/"+id+"/statusId/"+statusId, function(data) {
	if(statusId==1){
			$("#status-"+id).text('禁用');
			$("#status-"+id).attr('name',0);
			$("#status-"+id).attr('class','red');
		}else{
			$("#status-"+id).text('启用');
			$("#status-"+id).attr('name',1);
			$("#status-"+id).attr('class','blue');
		}
	});
}

function checkForm(){
	var searchType = $("#searchType").val();
	var startTime = $("#startTime").val();
	var endTime = $("#endTime").val();
	var d1 = parseInt(new Date(startTime).getTime()/1000/60/60/24);
	var d2 = parseInt(new Date(endTime).getTime()/1000/60/60/24);
	if(searchType==10){
		if(startTime==''){
			msg('请选择搜索时间！','warning',2);
			return false;
		}
		if(startTime>endTime && endTime!=''){
			msg('开始时间不能大于结束时间！','warning',2);
			return false;
		}

		if(d2-d1>60){
			msg('一次最多只能查询两个月的统计！','warning',2);
			return false;
		}
	}
	return true;
}
</script>